package cn.itsource.org.controller;

import cn.itsource.common.util.AjaxResult;
import cn.itsource.org.ro.BindRo;
import cn.itsource.org.ro.LoginRo;
import cn.itsource.org.service.ILoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private ILoginService loginService;


    @PostMapping
    public AjaxResult login(@RequestBody @Validated LoginRo loginRo){
        return loginService.login(loginRo);
    }

    @GetMapping("/wechat/{code}")
    public AjaxResult wechat(@PathVariable("code")String code){
        //发送第二个请求
        return loginService.wechat(code);
    }

    @PostMapping("/bind")
    public AjaxResult bind(@RequestBody BindRo bindRo){
        //发送第二个请求
        return loginService.bind(bindRo);
    }
}
